const path = require("path");
const HTMLWebpackPlugin = require("html-webpack-plugin"); // 自动把打包的js 挂在到 html 文件上
const srcPath = path.join(__dirname, "03-webpack-demo", "src", "index.js");
console.log("打包路径", srcPath);
module.exports = {
  mode: "development",
  entry: srcPath,
  output: {
    filename: "bundle.js",
    path: path.join(__dirname, "dist"),
  },
  module: {
    rules: [
      {
        test: /\.js/,
        loader: ["babel-loader"],
        include: path.join(__dirname, "03-webpack-demo", "src"),
        exclude: /node_modules/,
      },
    ],
  },
  plugins: [
    new HTMLWebpackPlugin({
      template: path.join(__dirname, "03-webpack-demo", "src", "index.html"),
      filename: "index.html",
    }),
  ],
  devServer: {
    port: 3001,
    contentBase: path.join(__dirname, "dist"),
  },
};
